using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FrameWork.Source.FrameWork;
using FrameWork.Source.Texture;
using FrameWork.Source.CMenu_class;
using Microsoft.Xna.Framework.Graphics;
using FrameWork.Source.Resource_Manager;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using FrameWork.Source.ReadWrite_class;
using FrameWork.Source.Global_variables;
using Boomer.Source.FrameWork.State_and_Screen_Manager.Screen_Manager;
using Boomer.Source.FrameWork.State_and_Screen_Manager.State.MenuState.MenuScreen;
using Boomer.Source.Sound_Manager;

namespace FrameWork.Source.Screen
{
    class MainMenuState : IGameState
    {
        ScreenManager m_pScreenManager;

        public MainMenuState(StateManager pState)
            : base(pState)
        {
            m_pScreenManager = new ScreenManager(m_pState);
            m_pScreenManager.addScreen(new MainMenuScreen(0, "mainmenu screen", false, m_pScreenManager));
            m_pScreenManager.addScreen(new AboutScreen(1, "about screen", false, m_pScreenManager));
            m_pScreenManager.addScreen(new OptionScreen(2, "option screen", false, m_pScreenManager));
        }


        public override void init()
        {
            CResourceManager.getInstance().loadImage(CResourceManager.RES_STATE.RES_STATE_MENU , m_pState);
            m_pScreenManager.init();

            m_pScreenManager.setScreen("mainmenu screen", false , true);

            SoundManager.getInstance().init(this.m_pScreenManager);

            MediaPlayer.Play(SoundManager.getInstance().menuTheme);
            base.init();
        }

        public override void update(GameTime gameTime)
        {
            m_pScreenManager.update(gameTime.ElapsedGameTime.Milliseconds / 1000.0f);
            base.update(gameTime);
        }

        public override void render(GameTime gameTime)
        {
            m_pState.m_pSpriteHandler.Begin();
            m_pScreenManager.render();
            m_pState.m_pSpriteHandler.End();
            base.render(gameTime);
        }

        public override void destroy()
        {
            base.destroy();
        }
    }
}
